package com.vpx.server.controller.system;

import com.vpx.server.bean.order.base.BaseDelOrder;
import com.vpx.server.bean.order.base.BaseDeleteOrder;
import com.vpx.server.bean.order.base.BaseIdOrder;
import com.vpx.server.bean.order.base.BaseIdStrOrder;
import com.vpx.server.bean.order.system.*;
import com.vpx.server.bean.result.system.*;
import com.vpx.server.framework.authority.AuthPoicy;
import com.vpx.server.framework.authority.RequestAuth;
import com.vpx.server.framework.base.ResultMsg;
import com.vpx.server.service.system.ProjectService;
import com.vpx.server.service.system.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 工程管理
 */
@RestController(value = "projectengineeringController")
@RequestMapping(value = "/api/project")
@Api(tags = "工程管理")
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @PostMapping("/insertPorject")
    @ApiOperation("新增工程")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg insert(@RequestBody ProjectOrder order) {
        return projectService.saveProject(order);
    }

    @DeleteMapping("/deleteProject")
    @ApiOperation("删除工程")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg deleteById(@Validated @RequestBody BaseDelOrder order) {
        return projectService.deleteById(order);
    }

    @PostMapping("/updateProject")
    @ApiOperation("修改工程")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateById(@RequestBody ProjectOrder order) {
        return projectService.updateProjectById(order);
    }

    @GetMapping("/selectProjectById")
    @ApiOperation("查询工程")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<ProjectResult> selectById(BaseIdStrOrder order) {
        return projectService.selectProjectById(order);
    }

    @GetMapping("/pageQueryProject")
    @ApiOperation("分页查询工程")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<ProjectPageResult> pageQueryProject(ProjectPageOrder order) {

        return projectService.pageQueryProject(order);
    }

    /**
     * 打开工程
     * @param projectId
     * @return
     */
    @GetMapping("/getProjectInfo")
    @ApiOperation("选择工程后返回工程详情")
    public ResultMsg getProjectInfo(@RequestParam @ApiParam(value = "工程ID", name = "projectId") String projectId) {
        return ResultMsg.success(projectService.getProjectInfo(projectId));
    }



}
